package com.crm.repository;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.crm.entity.Dynamicmessages;

public interface MessageRepository extends JpaRepository<Dynamicmessages, Integer>{

	/**
	 * 添加动态消息记录
	 * @return
	 */
	@Modifying
	@Transactional
	@Query(value = "insert  into dynamicmessages(`message_content`, `start_id`, `receive_id`) values(?1,?2,?3)" ,nativeQuery = true)
	Integer addDyniMessage(String message_content, String startId, String receive);
	
	
	
	
			/**
			 * 查询未回复的记录
			 * @return
			 */
			@Modifying
			@Transactional
			@Query(value = "select * from dynamicmessages where is_reply=0 and receive_id=?1" ,nativeQuery = true)
			List<Dynamicmessages> checkDyniMessage(String receiveId);		
}
